<?php

namespace App\Api\Dao;

use App\Models\TongGoodsGroup;

class GoodsGroupDao extends BaseDao
{

    /**
     * 查询构造器
     * @param $data
     * @return \Illuminate\Database\Eloquent\Builder
     */
    function getBuildQuery($data)
    {
        // TODO: Implement getBuildQuery() method.
        $query = TongGoodsGroup::query();
        if(checkIsHasField($data,'id')){
            $query->where('id',$data['id']);
        }
        if(checkIsHasField($data,'goods_status')){
            $query->where('goods_status',$data['goods_status']);
        }
        return $query;
    }

    /**
     * 获取套餐商品列表
     * @param array $data
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|void
     */
    public function getGroupGoods(array $data)
    {
        return $this->getBuildQuery($data)->with(['values'])->get();
    }

    /**
     * 获取套餐的详情
     * @param array $data
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|void
     */
    public function getGroupGoodsInfo(array $data)
    {
        return $this->getBuildQuery($data)->with(['values'])->first();
    }


}
